<template>
  <div class="content-block block-2">
    <div class="info-head">{{ title }}</div>
    <div class="info-content">
      <v-chart :option="chartOption" style="width:100%;height:500px;"></v-chart>
    </div>
  </div>
</template>

<script>
export default {
  name: 'grid-item-two',
  props: ['title'],
  computed: {
    chartOption () {
      // TODO
      const months = ['2022-11', '2022-12', '2023-1', '2023-2', '2023-3', '2023-4']
      const lines = ['产值', '产值电耗', '产值单耗']
      return {
        legend: {
          left: 'center',
          bottom: '5%'
        },
        grid: {
          left: '5%',
          right: '12%',
          bottom: '20%'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross'
          }
        },
        xAxis: {
          type: 'category',
          data: months
        },
        yAxis: [
          {
            type: 'value',
            name: '亿元',
            position: 'left',
            axisLine: {
              show: true
            }
          },
          {
            type: 'value',
            name: '千瓦时/万元',
            position: 'right',
            axisLine: {
              show: true
            }
          },
          {
            type: 'value',
            name: '千克标准煤/万元',
            position: 'right',
            offset: 100,
            axisLine: {
              show: true
            }
          }
        ],
        series: [
          ...lines.map((v, i) => ({
            type: i < 2 ? 'line' : 'bar',
            name: v,
            smooth: true,
            yAxisIndex: i,
            data: months.map(() => Math.round(Math.random() * 200 + 100))
          }))
        ]
      }
    }
  }
}
</script>

<style scoped>

</style>
